using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;

namespace SingleUserWebsite.DAL
{
    public static class DAL
    {

        private static SqlConnection GetConnectionToDatabase()
        {

            SqlConnection ourConn = new SqlConnection();

            if (ConfigurationManager.AppSettings["ConnectionString"] != null)
            {

                ourConn.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];

                try
                {
                    ourConn.Open();
                }
                catch
                {
                    throw new Exception("Error connecting to Database");
                }

            }

            else
            {
                throw new Exception("Configuration error, connection string missing");

            }

            return ourConn;

        }

    }
}
